<script setup>
import baseModel from "@/components/baseModel/baseModel.vue";
import { reactive, ref, computed } from "vue";
import request from "@/common/utils/request";
import { message } from "ant-design-vue";

const emit = defineEmits(["editSubmit"]);

const props = defineProps({

})
const dialog = ref(null)

const state = reactive({
    scene_des: '', // 描述
    subtitle_content: '', // 内容
    // 打开抽屉获取的编辑行 参数
    itemData: {}
})

// 点击确定
const submit = async () => {
    const params = {
        ...state.itemData,
        scene_des: state.scene_des,
        subtitle_content: state.subtitle_content
    }
    try {
        const res = await request.put("/work_ai", "/user/shotstack/inspirationText/split/update", params)
        emit('editSubmit')
        close()
    } catch (err) {
    }

}

const open = (data) => {
    // 初始赋值
    state.scene_des = data.scene_des
    state.subtitle_content = data.subtitle_content
    state.itemData = data
    dialog.value && dialog.value.showModal()
}

const close = () => {
    dialog.value && dialog.value.closeModal()
}


defineExpose({
    open,
    close
})

</script>

<template>
    <div>

        <baseModel ref="dialog" :title="'镜头组-场景'" :zIndex="1100" @submit="submit" :contentWidth="620" @cancel="close">
            <template #content>
                <div class="content">
                    <div class="content_item">
                        <span class="title">字幕内容</span>
                        <a-textarea v-model:value="state.subtitle_content" placeholder="请输入字幕内容" :rows="4"
                            allow-clear />
                    </div>
                    <div class="content_item">
                        <span class="title">场景描述</span>
                        <a-textarea v-model:value="state.scene_des" placeholder="请输入场景描述" :rows="4" allow-clear />
                    </div>
                </div>
            </template>

        </baseModel>

    </div>
</template>

<style lang="less" scoped>
.content {}
</style>